from flask import Flask, request, jsonify

app = Flask(__name__)

# 示例用户数据（在实际应用中，应该从数据库获取）
users = {
    "admin": {"password": "123456", "roleList": [{"id": 1}], "token": "abcdef"}
}

@app.route('/api/userService/v1/webLogin', methods=['POST'])
def login():
    data = request.json
    username = data.get("username")
    password = data.get("password")

    # 验证用户
    if username in users and users[username]["password"] == password:
        # 登录成功，返回用户数据
        return jsonify({
            "status": 0,
            "data": {
                "roleList": users[username]["roleList"],
                "token": users[username]["token"]
            },
            "message": "登录成功"
        })
    else:
        # 登录失败
        return jsonify({
            "status": 1,
            "message": "用户名或密码错误"
        })

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8088, debug=True)